import React from "react";
import Image from './Image';

export default class App extends React.Component {

  //https://source.unsplash.com/500x400?animal
  // 声明状态 保存关键字数据
  state = {
    keyword: 'animal'
  }

  render() {
    //返回虚拟 DOM 
    return <div>
      <h2>图片查看器</h2>
      <hr />
      <button onClick={() => {this.setState({keyword: 'computer'})}}>电脑</button>
      <button onClick={() => {this.setState({keyword: 'phone'})}}>手机</button>
      <button onClick={() => {this.setState({keyword: 'car'})}}>汽车</button>
      <hr />
      <Image keyword={this.state.keyword} />
    </div>;
  }
}
